import {ref} from 'vue'
import { defineStore } from 'pinia'
import { searchAPI } from '../apis/common'

export const useSearchStore = defineStore('search', () => {
    
  const input = ref('')
  const list = ref([])

  const search = async() => {
    if (input.value != '') {
      const res = await searchAPI(input.value)
      list.value = res.data
    } else {
      alert('提示：请输入小说名称或作者名字！')
    }
  }
    return {
      input,
      list,
      search
    }
  }
)
